import _regeneratorRuntime from "@babel/runtime/regenerator";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
var _excluded = ["organizationId"];

/**
 * service 采购组织
 * @date: 2018-7-9


 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
/**
 * 查询采购组织
 * @param {Object} params - 查询参数
 * @param {String} params.organizationId - 租户ID
 * @param {String} params.page - 页码
 * @param {String} params.size - 页数
 */

export function fetchPurchaseOrgList(_x) {
  return _fetchPurchaseOrgList.apply(this, arguments);
}
/**
 * 批量新增编辑采购组织
 * @param {Object} params - 参数
 * @param {String} params.organizationId - 租户ID
 * @param {Array} params.purchaseOrgList - 数据列表
 * @param {String} params.enabledFlag - 启用标识
 * @param {String} params.organizationCode - 采购组织代码
 * @param {String} params.organizationName - 采购组织名称
 * @param {String} params.purchaseOrgId - 采购组织ID
 * @param {String} params.sourceCode - 数据来源代码
 */

function _fetchPurchaseOrgList() {
  _fetchPurchaseOrgList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var organizationId, other;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            organizationId = params.organizationId, other = _objectWithoutProperties(params, _excluded);
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/purchases/organizations"), {
              method: 'GET',
              query: other
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _fetchPurchaseOrgList.apply(this, arguments);
}

export function savePurchaseOrg(_x2) {
  return _savePurchaseOrg.apply(this, arguments);
}

function _savePurchaseOrg() {
  _savePurchaseOrg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(params.organizationId, "/purchases/organizations/batch-save"), {
              method: 'POST',
              body: params.purchaseOrgList
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _savePurchaseOrg.apply(this, arguments);
}